package com.dq.Week1.day05;

import java.util.Random;

public class Student {

    public Student(){
        System.out.println("这是学生的无参构造方法");
    };
    public Student(String name)
    {
        System.out.println("这是学生的有参构造方法");
    }

    //属性
    String name;
    String sex;
    int age;

    double height;

    double weight;


    String color = "yellow";

    int studyHours;

    int happy;

    int codeLineNum;

    int devAbility;
    //方法

    public void run(){
        Random random = new Random();
        int time = 1+random.nextInt(60);
        System.out.println(name+"在跑步，跑了"+time);
        weight = weight-1;
        happy = happy+1;
    }

    public void playGame(){

        Random random = new Random();
        int time = 1+random.nextInt(60);
        if(time>30)
        {
            devAbility = devAbility-5;
        }
    }



    //函数重载，参数列表有差异
    public void playGame(int minutes)
    {
        if(minutes<=60)
        {
            devAbility = devAbility+1;
            happy +=1;
            System.out.println(name+"开心了，心情值为："+happy);

        }else if(minutes>60)
        {
            devAbility -=1;
            happy -=1;
            System.out.println(name+"玩太久了，后悔了，心情值为："+happy);
        }

    }

    public void playGame(int minutes,Student player)
    {
        if(minutes<=60)
        {
            devAbility = devAbility+1;
            happy +=1;
            System.out.println(name+"开心了，心情值为："+happy);

            player.happy = player.happy +=2;
            System.out.println(player.name+"更开心了，心情值为："+player.happy);


        }else if(minutes>60)
        {
            devAbility -=1;
            happy -=1;
            System.out.println(name+"玩太久了，后悔了，心情值为："+happy);
            player.happy = player.happy -=2;
        }
    }

    public void addLindCode(int nunber){
        this.codeLineNum = this.codeLineNum+nunber;
    }
    public void study(){
        System.out.println(name+"在学习");
        this.addLindCode(100);//this可以调用实力实列方法
    }
}
